﻿using UnityStandardAssets.CrossPlatformInput;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class MyFreeLookCam : MonoBehaviour
{
    public CinemachineFreeLook freeLookCam;
    public TouchPad touchPad;

    public CinemachineVirtualCameraBase f1;
    public CinemachineVirtualCameraBase f2;
    public CinemachineBrain cinemachineBrain;

    private CameraCutEffect cameraCutEffect;
    public bool isF1 = false;

    void Awake()
    {
        CinemachineCore.GetInputAxis = GetInputAxis;
    }

    void Start()
    {
        cameraCutEffect=FindObjectOfType<CameraCutEffect>();
        cinemachineBrain.m_CameraActivatedEvent.AddListener((camera1, camera2) =>
        {
            Debug.Log(camera1?.VirtualCameraGameObject.gameObject.name);
            Debug.Log(camera2?.VirtualCameraGameObject.gameObject.name);

        });
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            f1.VirtualCameraGameObject.SetActive(isF1);
            f2.VirtualCameraGameObject.SetActive(!isF1);
            isF1 = !isF1;
        }
    }
    private float GetInputAxis(string axisName)
    {
        //Debug.Log(CrossPlatformInputManager.GetAxis("Horizontal"));
        if (axisName == "Horizontal")
        {
            return touchPad.xValue;
        }
        if (axisName == "Vertical")
        {
            return touchPad.yValue;
        }
        return 0;
    }
}
